function Get-ScriptDirectory
{
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value
    Split-Path $Invocation.MyCommand.Path
}

cd (Get-ScriptDirectory)

$rev = "dev"
if ($args.Length -eq 1) {$rev = $args[0]}

$targetfilename = "3DTicTacToe-$rev-Bin.zip"
$itemlist = "..\Resources\COPYING.txt","..\bin\3DTicTacToe.exe","..\bin\3DTicTacToe.Core.dll","..\bin\Lidgren.Network.dll","..\bin\Newtonsoft.Json.dll","..\bin\Microsoft.WindowsAPICodePack.dll","..\bin\Microsoft.WindowsAPICodePack.Shell.dll"

echo "Creating binary archive: $targetfilename"
echo "================================================================================"

echo "Testing for existing archive ..."
if (Test-Path $targetfilename) 
{ 
    echo "deleting"
    Remove-Item $targetfilename
}

foreach ($file in $itemlist)
{
    $realfilename = Resolve-Path "$file"
    .\7za a -tzip "$targetfilename" "$realfilename"
}

.\7za t "$targetfilename"

echo "================================================================================"
echo "Binary archive created!"